package com.myactiviti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.Test;

/**
 * 监听测试
 */
public class testlistener {

    /**
     * 加载流程
     */
    @Test
    public void test1(){
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = defaultProcessEngine.getRepositoryService();
        repositoryService.createDeployment()
                .addClasspathResource("flow/demo-listener.bpmn")
                .name("listener请假申请")
                .deploy();
        System.out.println("流程加载完成");

    }

    /**
     * 执行流程
     */
    @Test
    public void test2(){
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();
        RuntimeService runtimeService = defaultProcessEngine.getRuntimeService();
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("demo-listener");
        System.out.println("------>"+processInstance.getStartUserId());
        System.out.println("------>"+processInstance.getId());


    }
}
